package app.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springleaf.core.mvc.controller.JsonApiController;
import org.springleaf.core.query.QueryObject;
import org.springleaf.utils.Obj2MapUtils;

import app.demo.model.Menu;
import app.demo.service.MenuService;

/**
 * 菜单Action
 * @author leaf
 *
 */
@Controller
@RequestMapping("/menu")
@SuppressWarnings("rawtypes")
public class MenuAction extends JsonApiController<Menu> {

	@Autowired
	private MenuService menuService;


	@Override
	@RequestMapping("list")
	public ModelAndView list(QueryObject queryObj) throws Exception{
		queryObj.addQuery("obj.parent = null");
		List list = Obj2MapUtils.toMapList(menuService.query(queryObj)
				.getResult());
		return renderJson(list);
	}

}
